<!DOCTYPE html>
<script>
if (window.testRunner)
    testRunner.waitUntilDone();

function start() {
    document_clone = document.cloneNode(false);
    style1 = document_clone.createProcessingInstruction('xml-stylesheet', 'href="fail.css" type="text/css"');
    iframe1 = style1.ownerDocument.createElement('iframe');
    style2 = document_clone.createProcessingInstruction('xml-stylesheet', 'href="fail.css" type="text/css"');
    document_clone.insertBefore(style2, document_clone.firstChild);
    doc = document.documentElement;
    iframe1.appendChild(doc);
    document_clone = null;
    style2 = null;
    iframe2 = doc.ownerDocument.createElement('iframe');
    gc();
    iframe2_clone = iframe2.cloneNode(true);
    div = document.createElement('div');
    div_clone = div.cloneNode(false);
    iframe2_clone.appendChild(div_clone);
    iframe3 = div_clone.ownerDocument.createElement('iframe');
    style3 = iframe3.ownerDocument.createProcessingInstruction('xml-stylesheet', 'href="fail.css" type="text/css"');
    iframe3.ownerDocument.insertBefore(style3, iframe3.ownerDocument.firstChild);
    reload_page();
}

function reload_page() {
    if (location.hash == '#done') {
        document.write('PASS');
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.notifyDone();
        }
        return;
    }

    var count = 0;
    if (location.hash !== "")
        count = parseInt(location.hash.substr(1));
    if (count < 10) {
        ++count;
        location.hash = '#' + count;
    } else {
        location.hash = 'done';
    }
    setTimeout("gc(); location.reload();", 100);
}
</script>
<body onload="start()"></body>
